<template>
	<view>
		<Header>
			提案工作
		</Header>
		<uni-list v-show="data.length > 0">
			<uni-list-item direction="row" v-for="item in data" :key="item.id" :to="`/pages/resumption/proposalDetail?id=${item.id}`">
				<template v-slot:body>
					<view class="uni-list-box uni-content">
						<view class="title uni-ellipsis-2">
							{{item.title}}<span v-if="item.status_text && item.status_text != ''">【{{item.status_text}}】</span>
						</view>
						<view class="date">
							{{item.createtime_text}}
						</view>
					</view>
				</template>
			</uni-list-item>
		</uni-list>
		<uni-load-more v-if="showLoad" :status="loadStatus" />
		<image src="https://zhzx.on-line-demo.com/image/zwsj.png" mode="aspectFit" class="no-data"
				v-if="loadStatus == 'no-more' && data.length == 0"></image>
	</view>
</template>

<script>
	import request from '../../common/request.js'
	import Header from '../../components/header.vue'
	export default {
		components: {
			Header
		},
		data() {
			return {
				data:[],
				page: 1,
				loadStatus: 'loading',
				showLoad: false,
			}
		},
		mounted(){
			this.getListData()
		},
		onReachBottom() {
			if (this.loadStatus != 'loading') {
				this.loadStatus = 'loading'
				this.showLoad = true
				this.page++
				this.getListData()
			}
		},
		methods: {
			getListData(){
				request({
					url:'/proposal/tianList',
					data:{
						page: this.page,
						category: 1,  // 1我的，2草稿，3公开
					},
					method:'POST',
				}).then(res => {
						if(res.code == 1){
							this.data = this.data.concat(res.data)
							if(this.page == res.lastPage){
								this.loadStatus = 'no-more'
							}else{
								this.loadStatus = 'more'
								this.showLoad = false
							}
						}else{
							this.loadStatus = 'no-more'
							// uni.showToast({
							// 	title: res.msg,
							// 	icon: 'none',
							// 	duration: 2000
							// });
						}
					})
			},
		}
	}
</script>

<style scoped>
	
	.title span,
	.title label{
		color: #fb7a30;
	}
</style>